package com.chinasoft.maysham.manager.request;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

@EqualsAndHashCode(callSuper = true)
@Data
public class PageableRequest extends Request {

    private int page;

    private int size;

    public void resolvePage() {
        page = page <= 0 ? 1 : page;
        size = size <= 0 ? 10 : size;
    }

    public Pageable pageable() {
        return PageRequest.of(page, size);
    }
}
